package org.xtown.bingluo.xtieba.utils;

import android.app.Activity;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.widget.Toast;

public class UiUtils {
	private static final class UiUtilsHolder {
		private static final UiUtils INSTANCE = new UiUtils();

		/**
		 * Private Constructor.
		 */
		private UiUtilsHolder() {
		}
	}

	private static Context mC = null;

	/**
	 * Get the unique instance of the Controller.
	 * 
	 * @return The instance of the Controller
	 */
	public static UiUtils getInstance(Context c) {
			if (UiUtils.mC == null) {
				UiUtils.mC = c;
		    }
			return UiUtilsHolder.INSTANCE;
	}

	/**
	 * Private Constructor.
	 */
	private UiUtils() {

	}

	public void CreateShowToast(CharSequence text, int duration) {
		Toast toast = Toast.makeText(mC, text, duration);
		toast.show();
	}
	
	public void CreateShowToast(int rid, int duration) {
		Toast toast = Toast.makeText(mC, mC.getResources().getString(rid), duration);
		toast.show();
	}
	
	public static void settingScreenOrientation(Activity a,Boolean autohorscreem) {
		if (!autohorscreem) {
			//false不自动横屏，设置一直竖屏
			System.out.println("false不自动横屏，设置一直竖屏");
			a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
		} else {
			//true自动横屏，设置随系统自动切换
			System.out.println("true自动横屏，设置随系统自动切换");
			a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
		}
	}

}
